import random
import numpy as np
import pandas as pd


def generate_random_number(average):
    # 计算标准差
    std_dev = average / 20
    # 生成随机数
    random_number = random.gauss(average, std_dev)
    # 确保结果是整数
    n = int(round(random_number))
    return 5 * (n // 5)


def make_random():
    # 生成100个正态分布的随机数，平均值为0，标准差为1
    random_numbers = np.random.normal(75, 7, 20)
    random_numbers = np.floor(random_numbers).astype(int)
    return np.sort(random_numbers)


df = pd.DataFrame()
df['第1次'] = make_random()
df['第2次'] = make_random()
df['第3次'] = make_random()
df['第4次'] = make_random()
print(df)

"""
df = pd.DataFrame(random_numbers, columns=['目标均值'])
df['目标均值'] = df['目标均值'].apply(round)
df.sort_values(by='目标均值', inplace=True, ascending=False)

# print(df)

for i in range(1, 1 + 5):
    column = f'第{i}次'

    # 产生原始随机成绩
    df[column] = df['目标均值'].apply(generate_random_number)

df.insert(1, '实际均值', df.loc[:, '第1次':].mean(axis=1))

print(df)
"""
